/**
 * Created by Administrator on 2018/7/23 0023.
 */
/*function register_name(){
    //var username=document.getElementById("username").value;
    var name=$('#username').val();
    var check1=$("#check1");
    if(name==''){
       // document.getElementById('check1').innerHTML='不能为空';
        //$("#check1").html('不能为空');
        check1.html('不能为空');
        return false;
    }
    /*var ajaxObj =new XMLHttpRequest();
    ajaxObj.onreadystatechange=function(){
        if (ajaxObj.readyState==4){
            //document.getElementById('check1').innerHTML = ajaxObj.responseText;
            check1.html(ajaxObj.responseText);
        }
    }
    ajaxObj.open('get','../register/check?username='+username);
    ajaxObj.send(null);
    else {
            check1.html('');
    }
    /*$.get({url:('../register/check.html')},{"username":name},function(data){
        check1.html(data);
    });

}
function register_pas(){
    var password=document.getElementById("password").value;
    //password=encodeURIComponent(password);
    //console.log(password);
    if(password==''){
        document.getElementById('check2').innerHTML='不能为空';
        return false;
    }
    else if(password.length<6){
        document.getElementById('check2').innerHTML='密码不得少于6位';
        return false;
    }
    else {
        document.getElementById('check2').innerHTML='';
        return false;
    }
}
function register_rpas(){
    var repassword=document.getElementById("repassword").value;
    var password=document.getElementById("password").value;
    if(repassword==''){
        document.getElementById('check3').innerHTML='不能为空';
        return false;
    }
    if(repassword!=password){
        document.getElementById('check3').innerHTML='两次输入密码不一致';
        return false;
    }
    else {
        document.getElementById('check3').innerHTML='';
        return false;
    }
}
function register_email(){
    var email=document.getElementById("email").value;
    var check4=$('#check4');
    email=encodeURIComponent(email);
    if(email==''){
        check4.html('不能为空');
        return false;
    }
    else{
        check4.html('');
    }

}function register_code(){
    var code=document.getElementById("code").value;
    code=encodeURIComponent(code);
    if(code==''){
        document.getElementById('check5').innerHTML='不能为空';
        return false;
    }
    else {
        document.getElementById('check5').innerHTML='';
        return false;
    }
}
*/
function register_all(){
    var name=$('#username').val();
    var pas=$('#password').val();
    var repas=$('#repassword').val();
    var email=$('#email').val();
    var code=$('#code').val();

    $.get({url:('../register/register.html')},
        {"username":name,"password":pas,"repassword":repas,"email":email,"code":code},
        function(data){

            if (data=='0'){
                var i=window.confirm("注册成功");
                if(i!=0){
                    window.location="/index.php/index/login/index";
                }
            }
            else {
                alert(data);
            }
    });
}